import axios from 'axios'

//创建实例
export const httpRequest = axios.create({
    baseURL: '/api/',
    timeout: 5000,
})

//配置请求拦截

httpRequest.interceptors.request.use(
    config => {
        //在发送请求之前做些什么
        return config
    }, error => {
        //请求错误
        return Promise.reject(error)
    })

//配置响应拦截
httpRequest.interceptors.response.use(
    response => {
        //在发送请求之前做些什么
        return response.data.data
    }, error => {
        //请求错误
        return Promise.reject(error)
    })